<template>
	<view class="container">
		<view class="container-box">
			<view class="background-color" :style="'background:' + mobile_head_color">
				<view class="topbox">
					<view class="text">当前快递柜剩余{{numlist.express_count}}个柜子，其中大柜：{{numlist.express_max_conunt}}个；中柜：{{numlist.express_in_count}}个；小柜：{{numlist.express_small_count}}个</view>
				</view>
			</view>
			<view class="title">快递单号</view>
			<view class="select-box">
				<radio-group @change="radioChange" class="selectChange">
					<label class="box" v-for="(item,index) in listdata">
						<view>
							<radio :value="item.value" :checked="item.type == 1" />
						</view>
						<view>{{item.name}}</view>
					</label>
				</radio-group>
			</view>
			<view class="title">快递单号</view>
			<view class="input-box" @tap="selecttime">
				<input type="text" class="input-btn" v-model="num"  placeholder-style="padding-left: 30rpx;font-size: 28rpx;font-weight: normal;font-stretch: normal;line-height: 60rpx;letter-spacing: 0rpx;color: #c3c3c3;text-align:center"
				 placeholder="请输入快递单号">
				<view class="right-icon">
					<image src="../../../static/images/saoyisao.png" class="right-img"></image>
				</view>
			</view>
			<view class="title">手机号码</view>
			<input class="inp-box" v-model="phone" type="number"  placeholder-style="font-size: 28rpx;font-weight: normal;font-stretch: normal;line-height: 50rpx;letter-spacing: 0rpx;color: #c3c3c3;text-align:center"
			 placeholder="请输入手机号码" />
			<view class="title">姓名(非必填)</view>
			<input class="inp-box" v-model="name" type="text" placeholder-style="font-size: 28rpx;font-weight: normal;font-stretch: normal;line-height: 50rpx;letter-spacing: 0rpx;color: #c3c3c3;text-align:center"
			 placeholder="请输入姓名" />
		</view>
		<view class="btn">
			<button type="primary" :style="btn_style" class="btn-pry" @tap="uPublishTap">提交</button>
		</view>
	</view>
</template>

<script>
	var common = require('../../../utils/common.js');
	var app = getApp();
	var _this;
	const getvisitorList = () => {
		common.post('HouseApi&a=express_num_add_info', {
			equipment_id: '867394040230038',
		}, data => {
			console.log('++++', data)
			_this.numlist = data;
			_this.listdata = data.list;
			_this.express_num_id = data.list[0].value;
		});
	};
	const getaddExpress = () => {
		common.post('HouseApi&a=express_num_add', {
			equipment_id: _this.equipment_id,
			express_odd_numbers: _this.num,
			express_num_id: _this.express_num_id,
			phone: _this.phone,
			name: _this.name,
			express_name: _this.express_name,
		}, data => {
			console.log('++++', data)
			settime()
			uni.navigateTo({
				url:'/pages/village/smartExpressCabinet/courierManagement'
			})
		});
	};
	//轮训获取开门信息
	const getopenDoor = () => {
		console.log('_this', _this);
		common.post('HouseApi&a=get_train_express', {
			village_id: _this.village_id,
			pigcms_id: _this.pigcms_id,
			id: _this.id,
		}, data => {
			_this.type = data.type;
			if (_this.type == 1) {
				uni.showModal({
					title: common.changeTxt('提示'),
					content: common.changeTxt('门已开'),
					showCancel: false,
					confirmText: common.changeTxt('确定'),
					success: function(res) {
						if (res.confirm) {}
					}
				});
			}
		});
	};
	const settime = () =>{
		setInterval(function() {
			getopenDoor()
		}, 1000)
	}
	export default {
		data() {
			return {
				listdata: {},
				numlist: {},
				village_id: 0,
				pigcms_id: 0,
				actcolor: '',
				btn_style: '',
				mobile_head_color: '',
				num:'',
				name:'',
				phone:'',
				id: 0,
				current:0,
				equipment_id:'',
				express_name:'',
				express_num_id:'',
			}
		},
		onShow() {
			// #ifdef H5
			common.hideWxShare()
			// #endif
		},
		onLoad(options) {
			_this = this;
			_this.equipment_id = options.equipment_id
			
			// #ifdef H5
			console.log('准备跳小程序页', _this.id);
			common.webToMiniapp(_this.route, options, 'redirect')
			// #endif

			common.setMainColor(_this, function(config) {
				_this.mobile_head_color = config.config.mobile_head_color
				_this.actcolor = config.config.mobile_head_color
				_this.btn_style = 'background-color: ' + _this.actcolor + ';box-shadow:0px 30rpx 30rpx -30rpx ' + _this.actcolor +
					';';

				const res = uni.getStorageSync('village_key');
				if (res) {
					_this.village_id = res.village_id;
					_this.pigcms_id = res.pigcms_id;
					_this.village_name = res.village_name;
				};
				getvisitorList()
			});
		},
		methods: {
			radioChange(e){
				_this.express_num_id = e.detail.value;
				console.log("mmmmm",_this.express_num_id)
			},
			selecttime(){
				
			},
			//提交
			uPublishTap(){
				getaddExpress()
			},
		},
		components: {

		}
	}
</script>

<style>
	page {
		background: rgb(255, 255, 255);
	}

	.container {
		margin: 0;
		padding: 0;
	}

	.container-box {
		background: #FFFFFF;
	}

	.topbox {
		padding: 40rpx;
		display: flex;
		flex-direction: column;
		background-size: 30%;
	}

	.text {
		color: #FFFFFF;
	}

	.title {
		margin-left: 30rpx;
		font-size: 26rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 50px;
		letter-spacing: 0rpx;
		color: #333333;
	}

	.inp-box {
		background: #FFFFFF;
		margin: 0rpx 30rpx;
		padding: 30rpx;
		border-radius: 20rpx;
		border: 2rpx solid #CCCCCC;
	}

	.input-box {
		margin: 15rpx 30rpx 10rpx 30rpx;
		padding: 20rpx;
		background-color: #ffffff;
		border: 2rpx solid #CCCCCC;
		/* box-shadow: 0px 2rpx 11rpx 2rpx rgba(227, 227, 227, 0.33); */
		border-radius: 20rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}

	.input-btn {
		width: 100%;
	}

	.right-icon {
		width: 60rpx;
		height: 60rpx;
	}

	.right-img {
		width: 100%;
		height: 100%;
		display: block;
	}

	.btn {
		margin: 74rpx 0rpx;
		height: 100%;
		width: 100%;
	}

	.btn-pry {
		width: 550rpx;
		height: 98rpx;
		background: #2681f3;
		border-radius: 49rpx;
		line-height: 98rpx;
		margin-top: 220rpx;
	}
	.select-box {
		
	}
	.text2 {
		
	}
	.selectChange {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
	}
	.box {
		display: flex;
		flex-direction: row;
		justify-content: flex-start;
		align-items: center;
		margin-left: 30rpx;
	}
</style>
